<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 回调地狱 callback  
        // es6 promise then 链式调用 异步同步化 代码的编写顺序和执行顺序一致
        const async1 = async () => {
            console.log('async1');
            setTimeout(() => { // 放入event loop 宏任务中
                console.log('timer1')
            },2000)
            await new Promise(resolve => {  // promise {status:pending}
                console.log('promise') // resolve 没解决
                // resolve()
            })
            console.log('async1 end');
            return 'async1 succes'
        }
        console.log('script start');
        async1().then(res => console.log(res))
        console.log('script end');
        Promise.resolve(1) // 静态方法 
            .then(2)
            .then(Promise.resolve(3))
            .then(res => console.log(res))

        setTimeout(() => {
            console.log('timer2');
        },1000)
    </script>
</body>
</html>